package com.job.Gai_Yian.homework0701;

import java.util.Scanner;

/**
 * @author DELL
 * @version 1.0
 * @since 2022-07-04 11:15:41
 */
public class FindPerson {
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        System.out.println("请输入人数");
        int n=input.nextInt();
        int m=FindPerson.rule(n);
        System.out.println("获胜者人数："+m);
    }
    public static int rule(int n){
        int[] persons=new int[n];
        for (int i=0;i<persons.length;i++){
            persons[i]=i+1;
        }
        while (persons.length>3){
            int[] newpersons=new int[persons.length-1];
            for (int i=3;i<persons.length;i++){
                newpersons[i-3]=persons[i];
            }
            newpersons[newpersons.length-2]=persons[0];
            newpersons[newpersons.length-1]=persons[1];
            persons=newpersons;
        }
        return persons[1];
    }
}
